﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BLL;
using System.Data;


public partial class BrandCategory : System.Web.UI.Page
{

    BrandCateBLL dataBrandCate = new BrandCateBLL();
    ProdCateBLL dataProdCate = new ProdCateBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoatRptCateBrand();
            LoadListBrand();
        }
    }

    void LoatRptCateBrand()
    {
        var listBrandCate = dataProdCate.GetByParent(0);
        DataTable tb = Myfunction.ConvertToDataTable(listBrandCate);
        rptBrandCate.DataSource = tb;
        rptBrandCate.DataBind();
    }

    BrandBLL dataBrand = new BrandBLL();
    void LoadListBrand()
    {

        int idProdCate = 47;
        if(Request.QueryString["Id"]!=null)
            idProdCate = Convert.ToInt32(Request.QueryString["Id"]);
        var listBrand = dataBrandCate.GetAll();
        DataTable tb = Myfunction.ConvertToDataTable(listBrand);
        rptListBrand.DataSource = tb;
        rptListBrand.DataBind();
    }
    protected void rptBrandCate_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Repeater rptCateChild = (Repeater)e.Item.FindControl("rptCateChild");
        Label lbId = (Label)e.Item.FindControl("lbId");
        int CateId = int.Parse(lbId.Text);

        var listChild = dataProdCate.GetByParent(CateId);
        DataTable tb = Myfunction.ConvertToDataTable(listChild);
        rptCateChild.DataSource = tb;
        rptCateChild.DataBind();
    }
    protected void rptListBrand_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {

    }
}